home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 7589 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: sargas.omicron.se!usenet
  2. From: elias@cepheus.omicron.se (Elias Martenson)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: returning ptr to struct with ptrs in it?
  5. Date: 27 Feb 1996 15:55:01 GMT
  6. Organization: Omicron
  7. Message-ID: <ELIAS.96Feb27165501@cepheus.omicron.se>
  8. References: <4gk852INNbp4@faatcrl.faa.gov> <4glcrtINNf4b@faatcrl.faa.gov>
  9. NNTP-Posting-Host: graffias.omicron.se
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=US-ASCII
  12. Content-Transfer-Encoding: 7bit
  13. In-reply-to: lbona@saratoga's message of 23 Feb 1996 21:50:53 GMT
  14.  
  15. In article <4glcrtINNf4b@faatcrl.faa.gov> lbona@saratoga (lbona) writes:
  16.  
  17. > My real question is: why is it that if the struct ends with a pointer
  18. > or pointers, that area of memory is corrupted (made non-zero in this case)
  19. > yet if the struct ends in a non-pointer field the area of memory in 
  20. > question is not changed? All the data is the same, including pointers in 
  21. > the middle of the struct.
  22.  
  23. You shouldn't be thinking about these things, beacuse
  24. its UU (Utterly Unsupported) anyway. Actually it's Undefined Behaviour.
  25.  
  26. If you still want to know, I guess it's beacuse of pointer alignment,
  27. i.e. the struct is padded with some zeroes in the end, and those are
  28. the ones that get corrupted instead of the actual data following it.
  29.  
  30. -- 
  31. Elias Martenson                            ! When I come up with a good joke,
  32. elias@omicron.se                           ! it will be here.
  33.